remove unnecessary code and spaces