some changes, still not perfect