fixed bugs, compiles and runs