Updated space problem- added 'if'