Removed debug messages
Add error logging