Refactor: clearer code and comments