Re-orginazied compare to be a function