Restructure the code to match idiomatic Go