shorter conditions, less functions, better order