generator function need inprove
finish