Error handling and debug statemnet remval