need to fix some logic