fixed compilation and run time errors