For some reason this refactorization made it really slow