refactor and add features to completion