Refactored into codeigniter spark format