Finished logic for main activity