added valid item check with tests