Updated some code
Fixed bug