strip spaces correctly