Only basic logic. Unfinished version.