Updated key function, Reformatted