uploading dan's commented code