modernized the code