Reverted back to js, rewrote in jquery