Modified from my fork