Cast exception fixed