Added ability to specify number of times to cycle