refactor common code, add return values for verification, clean up logging messages