sorting+better 400 error handling