added check for empty inventory