code clean up and formating