Fixed syntax and compile errors, has runtime errs