Finish main functionality