refactored method
renamed variables
added doc