got rid of database; some refactoring