updated code according to tests