updated some logic