added documentation , make code cleaner