refactor order functionality