back function ported from bash