finishing main procedure