Changed getNMessages function in DAO