fixed and added build_query