If I put sleep 20 before the case/select statements it runs fine but you have to wait for it to run.