NullPointerException fix on put method