lab2 final code, resets to 1 instead of 0