finish general function