Refactor + add comments