added cleanup and sort