slight improvements to code efficiency