added function horizontal motion