some refactor to meet ruby styles