Fix bug causing incorrect result
Improve view
update db