move logic to single bash script