reordering/refactoring code