Made changes so that it works with both databases