seperated output to php from js into packets for server compatibility
with last commit