rewrite based on MEAN - mean.io