fixed bugs, add proper database