functions bug fixed