Move function call
Improve debug message
Optimize compare function