trimmed down the code based on feedback to make it more efficient