Minor tweak to logic for efficiency