formatted code and cleanup