fixed typo, added spaces to comparisons and renamed a function based on
Paul Virtanen comments