refactored with HTTP calls instead of tcp sockets