Raise error on invalid argument
Code cleanup