error checking and sort prepost if needed
cleanup