corrected errors in functions