common code blocks into functions