added pulse function, untested