Fixed to work with new db design