use the count to avoid going past the input