Fixed a typo and a minor optimization