optimization + more cleaning