some refactoring, fixes #2
go fmt