Factor out argument computation to one function