clean up some repeated code