updated code so that it could pass the jasmine test