Merge
Made the existing type check more robust