loaded check_connection to library
fixed check_connection handling