working proof of concept, needs eid generation (really messy code at the moment)