Refactor code in Ops class