split code; added order function