cleaning up and organizing code