finish main functionality