Simplified the code by removing RegExps for key manipulation.