updated with Kevin's code