made inputing and sorting work