connection check must be done first!