tick function throws null pointer exception :(