updated and simplified