Some refactoring.  Still not working