got rid of commented out code, fixed unit test, and added a debug version of apply