program stuck after few hours

1 - 9 hours? Are you looking at milis(); somewhere and not properly accounting for rollover?

-jim lee