added paramter pos to the 'rest' function