fixed two main bugs