v2 cleaned-up code