cleaned up some code for readability