Fixed possible case of ClassCastException