Fixes cast bug