Modified parseKey method, use map instead of explicit list operations