changed duplicate code to be 25 lines instead of 15