More efficient variable passing to function