functions corrected

bugs fixed