added comments and clean up variable naming