Recopied code as prior version wasn't working.