Fixing function return issue