fixed init function running twice