New code, refactored to match the CodeIgniter framework