close to working sync, I think