minor optimizations but still conform to pep8 standard