Incorporating Ryan's code comments