added database link, fixed bugs