ruby optimization