fixed database writing issues. need to fix issue about different charts for each day