implemented basic key replacement functions