Finish the main functionality