Why does this function need so many arguments?