added flowchar, made changes to couple functions adding statements.
cleaned up code and added comments