old code improved and renamed to simple