adding finish function