Working version (it seems).