avoid instanceOf
refactor