Fixed a small bug and added more debug