improved check connection