improve connection code. add connection check. add strings.