added unfinished inventory code, fixed a length bug