refactor term parsing into a method