added some print statements for debugging and addign some comments. Will do some refactoring after