First implementation, refactor