Add automatic border detection