structured code and added more sorting problems