simpler logic + micro optimization