complex implementation, with type dispatch, and data-directed programming