reorganizing declarations and removing console statements
simplifying with filename var
read file