fixing function errors