added docs, finished code