Refactored generation of exception message
Added missed return statements + corrected invalid array key