Updated retrieval of key - not tested yet