reworking for use w/ rewrite