fixed php error in some rare cases