Transferring code to CodeIgniter