Added a fix for a null pointer exception bug