update and change logic of submit query