fixed compile and runtime errors