fixed the major bugs