corrected some errors in code