as suggested by @crosbymichael we could use a type switch here