Working version, with/without GUI