some refactor & add comment