Cleaner code,prepare statements  

I've added cleaner code and prepare statements.