added more comments, changed 'continue' control flow