Added controller with working loop logic