most code condensed into 3 methods