refactor: use auto_ptr instead of delete before each return