use std::reverse instead of your function