refactor & improve code