Why is the cast necessary here?