Updated to use more pythonic syntax