debugging and optimizing