New implementation (more efficient)