Trying to make this a bit faster but the bottleneck seems to be the serializing when you have a big library