keeping the Arduino in a function for X time

grio:
I thought delay stays on that line for the given time.

You thought correctly. That is why the Blink Without Delay (BWOD) technique uses millis() and is preferable in this case.