only printing the needed parts of the function. added some debug stuff