WIP Refactor code