Added a more descriptive error message and checks for environment variables