Handling https
Refactoring