db bug fix and new selectGridSize helper