its almost the same code as above you should extract to single function