code cleanup and added comments