fully extracted guess fn and code refactoring