algo complete - clean code - style needed