Writing bad javascript