Arduino Mega 2560 + WiFi Shield + Motor Shield

Hi,
I am having trouble connecting my wifi shield to my mega, i cant install it as normal by just putting it on top because i need to connect both the wifi and a motor shield, i connected the required pins from the mega (50,51 and 52) to the appropriate ones on the wifi shield, and when i start up the sketch to connect to WPA (here: http://arduino.cc/en/Tutorial/ConnectWithWPA ) it replies saying the wifi shield isnt present, i know ive done something wrong (missed out something) but i'm not sure what.

Any help?
thanks. :slight_smile: