cleanup and added comments