improved for testing purposes