refactored to be more useable