Fixed NPE on the end