FIXED: typeof missed when checking returned variable