Restructured into smaller, cleaner methods