Incorporating Anna's code