Fixing compile error due to not returning a variable from a function