Changed strlen to strnlen