refactor v2. hope this works now