The effect of stress distribution on the shape and direction of hydraulic fractures in layered media