Added exeptions if invalid parameters are passed