fixing runtime errors