Updated the pasted code.