tested and modified