Implemented auto-grid adjusting