basic code refactor