added method for removing extra spaces