This is not an error. It is a failure of your code to work as it is supposed to work by your goals.
What did I say? What has EVERYONE said so far? You cannot set a default as you did.
Even though you pass in the number 18 as the limit, the first thing you do inside is reset that value to 21.
Instead, you need to think about how to test to see if limit was provided at all.