Add comment and fix error case bug