fix bug with cast