Refactored 03 based on code from 07