small refactor and added mouseenter and mouseleave events to the square to control resize class.