Unified code, added basic flow