change callback function to handle errors
allow port configuration