apns: refactor