clean up that todo by actually using instanceof