Added argument checking and error messages