- added limit parameter
- fixed a few conditional checks