Preventing overflow when passign value to setValue