Refactor code for annotations