connection to and from

code cleaned