len check is introduced

Signed-off-by: Delian Delchev <delian.delchev@gmail.com>