added better handeling of dymanic vars

used switch() instead of if(), reenabled control system