finish location function