fixing ClassCastExceptions