avoid using reflection based instanceof