Refactor & add comments