refactored and added grid class