implement rewind function