extract repeated code check