Implemented ordering checking function