updated api functions to be compatible with php 5.4 and below