refactor some parts
more data calculation