removing invalid spaces