Rough sketch, haven't really tested it yet.