Removed debug prints and more pythonic