Main can now handle enviroments correctly