updated so it can be run directly