functions corrected