Refactor mouseReleased method.