On that second block I think pickedslot should be slot.UID ? Assuming that is being used to set the item back to it.
When you drop item onto slot you need to pick the other item already in the slot, so I would start using a variable on the slot which contains the current item UID.
Then for this I would use a function as it's easier to open up picking again and pass through as a parameter the slot.variable I mentioned (which is the UID of the item already in it).
In the function say pick item where UID = param, and set position to picked_slot. This moves out the old item. After this you will need to run the logic that sets the slot.variable for both slots to the item that is in it, this could be another function that you call when dropping items.