optimize code for PDO