Refactored initialize method, broken into smaller methods