task 7: refactored for cycled buffer inner implementation