refactor camera logic