There is a simpler way to do this JS. Please remove this block and I'll show you.