attempted to condense code