add error message in red and fixing bugs in SQL requests