first working version with mode selector