clarify code, divided to smaller chunks