better commentary and split of code