I wonder if we couldn't have this passed as a function argument instead?