refactored to run code on form load