implemented is_sorted function and cleaned up print statements