Final Working Version, still needs cleanup