add relative postion feature and refactor some functions