fixing api compatibility. adding length support.