refactor and annotate