He moved to Morocco 1239 / 40 ( after the fall of Valencia in 1238 ) and continued to work for the sultan there .
He moved to Morocco in 1239/40 ( after the fall of Valencia in 1238 ) and continued to work for the sultan there .