How to do proper and trim inthe same function