Improving daemon loop