improved implementation of glitch effect