Modified from doadin and arco