Improved efficiency of code by:

1. forcing SQL to sort posts and return highest serial number
2. using PHP to force the mapping and max of any return values

Code has been tested.