refactored for bulk insert
added rudimentary phpdoc type hints
minor changes