clean up and organize code