made sure callbacks are handled more correctly
connection is not initiated in a separate thread