fixed casting exception problem