some code clean up done.
logic changes made.