Refactored to use circular array