slight improvement to code