Updated code with bug fixes
Deleted old sample controller