Fixed some errors on the code