bugfix wp8 code with help from Davide Borlizzi