simplified and cleaned