More idiomatic ruby and fixed module code