clean up code, make it smaller and more resistant to mistakes