cd correctly, stop script upon error