modified to pattern model and also post can now work