Refactor & Add authentication