Fixed a bug that was causing to throw a NullPointerException