Added check for undefined argument in checkLayout function