pulse decoder implementation (nice try!)