I've changed the implementation accordingly