moved utility functions to utils file
added connection state enum, and tweaked formatting