Increasing security & improving code for database connection.