added environmental checks