Changed some code execution logic in main view