Bug fix with argument checking