fixed checks to be instanceof