Why is this cast necessary?