Codes used in the second chapter