modifying check_connection funtion, code clean up