Fixed some bugs on both ruby scripts