works fine till fetch data from database