added luciano's new update with some modification