adding function to remove trailing spaces