Added comments and exception check for parameters