Add web service check and improve code efficiency