code complete with small refactoring