Refactored network calls code