fixed functions bug