refactor a bit and add a kue integration