Fixing 'Only variables can be passed by reference' issue