fixing function error