Code for password retrieval function