refactored url handler