Main Changes:

	-The last commit only worked for a few cases, so this is the correct code.