Fixed crash code