Cleaned up code to make it for more go-like