Refactored code and enabled camera flipping