Fixed NPE in math