Might be cleaner to write this like http://play.golang.org/p/wtr_kIctv2