fixed runtime errors (hopefully)