code from getting tile from db