refactoring code for clarity/simplicity