add some comments
improve position calculation to make it viewport aware