added PHPDoc, query method rewritten