Updated to work with CodeIgniter