code pulled into different method for readability
refactored based on r# suggestions
removed unused namespaces/typecasts