bug fixed & ruby coding style preserved