Support for switching networks. Refactor home()

Refactor the whole home() in main.py for better readability

Fix switching networks