refactor len() usage