Fixing bug with null return