change brendan's code to dave's code