Added step handling function