finished basic documentation and algorithm