fixing branchless logic