environment fix, error detection and handling