some refactor for R style code