Avoid nullpointerexception from networkthread