create if statement for connection