updated finish code