Fixed the exception. Thanks for @mattip for the fix.