corrected minor mistakes in functions