asInstanceof looks fishy, must be a better way ...