automatic grid fixing
refactoring