fixed issue with detecting the correct number of parameters