rewrite state machine in _loop() function to handle buffer durations