clipboard code refactor