Implemented pagination, troubleshot syntax, cleaned up code some and abstracted into specific functions.