added cast function