modification to check the previous one