The code is right, but then the series is just filled with 0, which is probably not what you need.