javascript to do some cleanup