Working Version, Needs more testing.