fixing weird ClassCastException