Added timeout and reattempts. Added better error handling