-minor changes
-logic should be complete, but null pointer exception left!