code refactor; WIP