further refined code for readability in main.py and added comments.