refactor code. fix unmask logic and remove unused class