replace a bunch of default argument handling with a function