new API 2.0, pirum forked code almost equals