remove duplicated code (errors), plus added missing time import