Fixes #4 - Added some if checks