Small refactoring
Type update
Added optional parameters and a null check