error handling and other improvements
go fmt
comments and better names