fixed undefined object length, and service unavailable error