added docs with theory of how it works