cleaned up branchless logic