Fix minor setData bug
Improve code