Added a check to ensure items are defined before use.