outsourced "submit" method from main.py and removed some redundancies