fix invinite wait for data
use enum instead of integer for State