finish function implementation