modified phase unwrapper (moved to separate file)