Improve code and add temporary DB code