cleanup and added few comments