Fixing database timeout