Updated code, added schematic