Modified scan activity to properly go back to the main activity.