Fix 'Local variables should not be declared and then immediately returned or thrown'