Added code to handle and convert keys