started to clean up the code