Improved ruby method
Better handling for ruby method