Fix casting exception