fixed two major bugs