fixing possible NullPointerException