models code moved to lib file