slight logic change to avoid potential bugs