Fixed nullpointerexception!

WORKING VERSION!