moving code into code igniter