genrator function test
reduce repeated codes