extract common code to common module