refactor greater/lesser/maximum/minimum