Rework of original code