casting to proper type