fixed logic/connect and added debug line