Implementing the cast and call logic