got rid of some duplication. Still need to actually make this _work_ though.