Combined Anthony's and Cameron's code.