Added delay parameter to simulate network's latency