small research, adopt/copy other's algorithm/pseudocode from inet.