Recoded and fixed some errors