split into a few function and changed error in book where it did not increase the count when 2 came up