Refactored for code review with Sanda