Running tasks synchronously properly