refactoring to support limit