refactored and moved common and database code to separate project