fix bash logic