added factory and queries