refactor param.length a bit