Refactor implementation, add ability to set limit dynamically