Fix function re declaration bug