move initialization steps to a common method