Reorganize code into class to encapsulate the camera logic