refactor a bit and set default value