make it wokring
minor bug fix
refactored env implementation