correctly handle custom types