Refactored but no longer works.