clean up and simplified the code and variable names