Refactor set()

Reduce code duplication in set()