remove code smell by using more idiomatic ruby