First implementation plus tests