new method
rewritten in ruby