how to create buffer for elapsed time ??

Good start, but always use unsigned long for variables associate with millis() or micros().

Study the "blink without delay" example that comes with the Arduino IDE.