Fixed small bugs when using the hasNext method in DBHelper