Fist refactor working version, WIP