Made the process() javascript method more robust.