fix order function