reordering, add some changes from https://github.com/RequestPolicyContinued/subscriptions/pull/6/
 * up to line 34