Program not working as intended

Perhaps you meant:
static unsigned long previousTime = 0;
so the value of 'previousTime' doesn't get reset to 0 every time you enter the function.