Move checkConnetion() below elements.