try to make this work less hackishly