You should return the pet you've given from this function up rather than storing it.