changed the function for sliding