refactor after codereview