Compressed the code of remove_controls subroutine