First implementation
more modifications