If number of bins is less than 60 for delay, the function crashes.
If that number is big enough, it works as expected
An easy solution would be to use sizes of the arrays: