Merged with David's Code