tested using input.txt