Added handling for connection failure
Clean and re-structure service