add ui and fix buffer index issue.