error fix for function