adding sorting func