redesigned set() function