introducins envs, better error handling, prepearing for tests