added n param
updated granularity