clean up code and fix user experience