simplify a lot the implementation
based on @xavierhainaux advices