rewrote getitem to make it much more readable