Fixed errors and removed debug prints