Fixed 2 main bugs:
1. Throwing an error for the getLimits helper function
2. Overwriting already used index when filling unused space