slight modification of code for readability