add daemon logic (doesnt work fully yet)