Trying to clean up logic flow in sh file