make this into a proc instead of copy/paste