Cleaned up code and removed useless db connection