now works on bash 3.x