improve codes, more flexebility