Rewrite vk-api as state machine