some modifications to the code