removed a bug and added debug information.