simplified and pure js