avoid null error
refactor and docs