added functionality and cosmetic changes