added debugging outside and inside while