Refactoring - second try

Thanks @gmccrackin. Seems like passing the parameter has indeed fixed it.