Fixed incomplete code - working copy