Fixed errors, code compiles and runs