bash logic cleanup