added database support, fixed syntax errors