Added ruby functions by @JoshuaTLieberman for comparison