made a bit more efficient