refactoring the isWeakAssignableFrom method