fixed the bug. it was a stupid endif in the wrong spot. code seems to work now.