refined code with a pulsar class