adjust the implementation about max length limitation according review comments
add check, if insert item failed, then return null