#7 Fixes opening and closing the connection