recoded to support version 2-0-stable