reimpletemented drag function and added a test