force_env now is directly called with optim. param - additionally started to structure the code