Cleaned up code by using numOfItems method