fixing cast bug