Added a direction parameter to prepare function. This way we know if we are comming from the next screen or the previous screen