Added Debugging and Condition Handling