modified and simplified