refactored advanced for better organization