Refactor comparison to return early when it is nonzero