This is wrong on so many levels.
Last created actor is unknown and will cause problems. In this instance actor inside a region is actor X. You can make joints only between two different actors. Create attribute actor and then then asign actor inside region that attribute and then make a joint between that attribute and actor inside a region in another instance.
Also, not sure, but I'd swap for each <> if mouse. Seems more logical to be executed when mouse released