improved documentation and added environment checks