tidy up the code, improve readability