added square tracking functionality to main.cpp