Created a function item_constructor and cleaned up the code