My own implementation of the bag