implemented trim trailing whitespaces