refactor finess function.