when cleared buffer tail should be one greater than the head