Modify several if-conditions to more readable view.
Exception improved. Added deactivated users check.
Change elsif-statement to case.