move logic out of initialize method