Using promises to deal with latency