updated with recent changes by jayflo