Fixed a small issues with DB querry