added functionality and passed junit test