Refactored for consistent use of ids