Needs refactoring, needs sorting out, needs hardening, needs everything. BUT WORKS! hurrah.