working - before separating functions