code clean up and formatting