added UTF ecoding to json_encode
last iteration of POF
Adde error handling