Fix bug in stage script