refactored pulsedb to be faster