modified to work with real DB