preventing ClassCastException in move refactoring