adding debugging and fixing multiple call bug