Updating Bill's code to fix bug