Add interval to resolve 'TypeError: a float is required' error and change starting elif to if