correcting function error