Move cast into api