added comments. begun slight restructure