3rd iteration of bug fix, fixed wrong use of trim