Changed app to detect current environment