updated code after spec writing