added length zero check