Added the logic for the magic trick c: