normalize function which manages the multiple spaces crezated.