handle length properly