changed js arrangement a bit