Use a better check for undefined on params
Make sure that we have at least one param in array value before removing last param