Modified code to fix some errors.