fix layout and db query