Refactor/cleanupcode