(cleanup) rewrites back end for conciseness. Passes all tests now