Added scan database functionality, not yet complete